package com.tanhua.autoconfig;

import com.baidu.aip.face.AipFace;
import com.tanhua.autoconfig.tmplate.AipTemplate;
import com.tanhua.autoconfig.tmplate.HuanXinTemplate;
import com.tanhua.autoconfig.tmplate.OssTemplate;
import com.tanhua.autoconfig.tmplate.SmsTemplate;
import com.tanhua.properties.AipProperties;
import com.tanhua.properties.HuanXinProperties;
import com.tanhua.properties.OssProperties;
import com.tanhua.properties.SmsProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;

//创建SmsProperties对象
//使yml文件生效
@EnableConfigurationProperties({SmsProperties.class, OssProperties.class, AipProperties.class, HuanXinProperties.class})
public class TanhuaAutoConfiguration {

    //短信服务
    @Bean
    public SmsTemplate getSmsTemlate(SmsProperties smsProperties){
        return new SmsTemplate(smsProperties);
    }

    //图片上传
    @Bean
    public OssTemplate getOssTemlate(OssProperties ossProperties){
        return new OssTemplate(ossProperties);
    }

    //初始化AipFace
    @Bean
    public AipFace getAipFace(AipProperties aipProperties){
        return new AipFace(aipProperties.getAppId(), aipProperties.getApiKey(), aipProperties.getSecretKey());
    }

    @Bean
    public AipTemplate getAipTemplate(){
        return new AipTemplate();
    }

    //环信
    @Bean
    public HuanXinTemplate huanXinTemplate(HuanXinProperties properties){
        return new HuanXinTemplate(properties);
    }
}
